<%@ include file="/includes.jsp" %>
<%@ include file="/header.jsp" %>

<h2>Administrate Events</h2>
<table>
    <thead>
    <tr>
        <th>Event</th>
        <th>Administrator</th>
        <th>Location</th>
        <th>Start Time</th>
        <th>End Time</th>
    </tr>
    </thead>
    <c:if test="${empty eventList}">
        <tr>
            <td colspan="5">
                You do not have any Events defined.
            </td>
        </tr>
    </c:if>
    <c:if test="${not empty eventList}">
        <c:forEach var="event" items="${eventList}">
            <tr>
                <td><a href="form?id=${event.id}">${event.name}</a></td>
                <td>${event.administrator.firstName} ${event.administrator.lastName}</a>
                </td>
                <td>${event.location}</td>
                <td>${event.startTime}</td>
                <td>${event.endTime}</td>
                <td>
                    <form method="GET" action="<c:url value="../event/form"/>" name="editEvent">
                        <input type="hidden" name="id" value="${event.id}"/>

                        <p class="submit"><input type="submit" value="Edit"/></p>
                    </form>
                </td>
                <td>
                    <form method="GET" action="<c:url value="../event/delete"/>" name="deleteEvent">
                        <input type="hidden" name="id" value="${event.id}"/>

                        <p class="submit"><input type="submit" value="Delete"/></p>
                    </form>
                </td>
            </tr>
        </c:forEach>
    </c:if>
</table>
<p>

<form method="GET" action="<c:url value="../event/form"/>" name="newEvent">
    <input type="hidden" name="userId" value="${user.id}"/>

    <p><input type="submit" value="Add New Event"/></p>
</form>
</p>

<%@ include file="../footer.jsp" %>
 